<template>
  <div>
    <!--    面包屑-->
    <div class="mianbaoxie">
      <el-breadcrumb separator-class="el-icon-arrow-right" style="position:fixed;top: 13%">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>商城管理</el-breadcrumb-item>
        <el-breadcrumb-item>促销管理</el-breadcrumb-item>
        <el-breadcrumb-item>添加促销活动列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div  class="add-item-box">
      <div class="box_table">
        <h2>添加促销活动</h2>
      </div>
      <el-scrollbar style="height:100%">
        <div class="biankuang">

        <div>
          <h3>选择促销活动类型:</h3>
          <div class="table-type">
                <el-input v-model="ptype.typeName" placeholder="添加促销类型" class="input1">
                  <el-button
                      slot="append"
                      icon="el-icon-plus"
                      @click="addPtype"
                  ></el-button>
                </el-input>

          <el-table
              :data="ptypes"
              style="width: 30%;">
            <el-table-column
                prop="typeName"
                label="促销活动名称"
                width="150px"
            >
            </el-table-column>
            <el-table-column
                width="100px"
                label="添加">
              <el-checkbox></el-checkbox>
            </el-table-column>
          </el-table>
        </div>
        </div>
        </div>
      </el-scrollbar>



    </div>
  </div>


</template>

<script>
export default {
  data(){
    return{
      ptype:{
        typeName:"",
      },
      ptypes:[],
    }
  },
  created(){
    this.loadData()
  },
  methods: {
    addPtype(){
      console.log(JSON.stringify(this.typeName))
      this.$axios({
        url: "/promotion/addPtype",
        method: "post",
        data: this.ptype
        // contentType: "text/html;charset=UTF-8"
      }).then(res => {
        if (res.data.code == 200) {
          alert("添加成功")
          this.updateViewVisible = false;
          this.typeName= ''
          this.loadData()
        } else {
          alert("添加失败")
          this.loadData()
        }
      })

    },
    loadData() {
      this.$axios({
        method: "get",
        url: "promotion/findptype",
      }).then(res => {
        if (res.data.code == 200) {
          this.ptypes = res.data.data
          console.log(this.ptypes)
        }
      })
    },


  }
}
</script>

<style scoped>
.add-item-box {
  width: 95%;
  height: 70vh;
  margin: 0 auto;
  background: #FFFFFF;
  box-shadow: 1px 4px 12px #000;
  overflow: hidden;
}
.biankuang{
  margin-left: 75px;
}
.table-type{
  margin-left: 100px;
}

</style>